package com.wyf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration // 配置类
@ComponentScan("com.wyf") // 设置扫描包范围
@EnableWebMvc // 启用mvc
public class MvcConfig {
    /**
     * 配置JSP的试图解析器
     * @return
     */
    @Bean // 将方法的返回值交给IOC维护
    public InternalResourceViewResolver resourceViewResolver() {
        // 得到试图解析器
        InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();

        // 设置试图的前缀和后缀
        internalResourceViewResolver.setPrefix("/WEB-INF/jsp/");
        internalResourceViewResolver.setSuffix(".jsp");

        return internalResourceViewResolver;
    }
}
